home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #1 / Amiga Plus CD - 2000 - No. 1.iso / Tools / Text / Edit / GoldED-Demo / installdata / golded / developer / scanner / examples / basic / basic.c
Encoding:
C/C++ Source or Header  |  1999-12-03  |  1.5 KB  |  61 lines

  1. /* -----------------------------------------------------------------------------
  2.  
  3.   Scan handler looking for BASIC subroutines (SUB or PROCEDURE).
  4.   
  5.   Scan handlers are plain functions (loadSeg()'ed): no standard C startup
  6.   code and no library calls permitted. We have to put string constants into
  7.   the code segment (DICE compiler: option -ms1).
  8.  
  9.   DICE:
  10.   
  11.   dcc basic.c -// -l0 -md -mRR -o golded:etc/scanner/basic
  12.  
  13.   ------------------------------------------------------------------------------
  14. */
  15.  
  16. #include <exec/types.h>
  17.  
  18. ULONG
  19. ScanHandlerBasic(__D0 ULONG len, __A0 char **text, __A1 ULONG *line)
  20. {
  21.     const char *version = "$VER: Basic 1.0 (" __COMMODORE_DATE__ ")";
  22.  
  23.     if (len > 4) {
  24.  
  25.         if (**text == 'S') {
  26.  
  27.             if (((*text)[1] == 'U') && ((*text)[2] == 'B') && ((*text)[3] == ' ')) {
  28.  
  29.                 // found SUB subroutine
  30.  
  31.                 *text += 4;
  32.  
  33.                 return(len - 4);
  34.             }
  35.         }
  36.         else {
  37.  
  38.             if (**text == '>') {
  39.  
  40.                 *text += 2;
  41.                 len   -= 2;
  42.             }
  43.  
  44.             if ((len > 10) && (**text == 'P')) {
  45.  
  46.                 if (((*text)[1] == 'R') && ((*text)[2] == 'O') && ((*text)[3] == 'C') && ((*text)[4] == 'E') && ((*text)[5] == 'D') && ((*text)[6] == 'U') && ((*text)[7] == 'R') && ((*text)[8] == 'E') && ((*text)[9] == ' ')) {
  47.  
  48.                     // found PROCEDURE
  49.  
  50.                     *text += 10;
  51.  
  52.                     return(len - 10);
  53.                 }
  54.             }
  55.         }
  56.     }
  57.  
  58.     return(FALSE);
  59. }
  60.  
  61.